﻿
using StudentAgeSaveEditor.Models;


namespace StudentAgeSaveEditor.SaveData
{
    
   
    internal struct ISaveData
    {
        public BaseModel? baseModel;
        public RoleModel? roleModel;
        public CommonEvtModel? commonEvtModel;
        public RoundModel? roundModel;
        public BagModel? bagModel;
        public ProfileModel? profileModel;
        public ShopModel? shopModel;
        public TipsModel? tipsModel;
        public RecordModel? recordModel;
        public FuncModel? funcModel;
        public GlobalModel? globalModel;

        public static ISaveData Init(Dictionary<string, ISaveLoadValue> value)
        {
            var savDdata = new ISaveData();
            foreach (var pair in value)
            {
                if (pair.Value == null) 
                    continue;
                switch (pair.Key)
                {
                    case "BaseMgr.model":
                        savDdata.baseModel = pair.Value as BaseModel;
                        break;
                    case "RoleMgr.model":
                        savDdata.roleModel = pair.Value as RoleModel;
                        break;
                    case "CommonEvtMgr.model":
                        savDdata.commonEvtModel = pair.Value as CommonEvtModel;
                        break;
                    case "RoundMgr.model":
                        savDdata.roundModel = pair.Value as RoundModel;
                        break;
                    case "BagMgr.model":
                        savDdata.bagModel = pair.Value as BagModel;
                        break;
                    case "ProfileMgr.model":
                        savDdata.profileModel = pair.Value as ProfileModel;
                        break;
                    case "ShopMgr.model":
                        savDdata.shopModel = pair.Value as ShopModel;
                        break;
                    case "TipsMgr.model":
                        savDdata.tipsModel = pair.Value as TipsModel;
                        break;
                    case "RecordMgr.model":
                        savDdata.recordModel = pair.Value as RecordModel;
                        break;
                    case "FuncMgr.model":
                        savDdata.funcModel = pair.Value as FuncModel;
                        break;
                    case "GlobalMgr.model":
                        savDdata.globalModel = pair.Value as GlobalModel;
                        break;
                    default:
                        break;
                }
            }

            return savDdata;
        }
    }
}
